package cn.edu.scau.cmi.lintianwei.zongheExperiment;

import javafx.fxml.FXML;

import javafx.scene.control.Button;
import javafx.stage.Stage;
import cn.edu.scau.cmi.lintianwei.client.AbstractFactoryMethodClients;
import cn.edu.scau.cmi.lintianwei.client.AdapterClients;
import cn.edu.scau.cmi.lintianwei.client.FactoryMethodClients;
import cn.edu.scau.cmi.lintianwei.client.HibernateClientsByDAO;
import cn.edu.scau.cmi.lintianwei.client.InterProgrammingClients;
import cn.edu.scau.cmi.lintianwei.client.SpringClients;
import cn.edu.scau.cmi.lintianwei.client.SpringHibernateClients;
import cn.edu.scau.cmi.lintianwei.client.ConsistentCompositeClients;
import cn.edu.scau.cmi.lintianwei.client.MultitionClient;
import cn.edu.scau.cmi.lintianwei.client.SafeCompositeClients;
import cn.edu.scau.cmi.lintianwei.client.SimpleFactorymethodClient;
import cn.edu.scau.cmi.lintianwei.client.SingletonClients;
import javafx.event.ActionEvent;

public class GUIController {
	@FXML
	private Button singleton;
	@FXML
	private Button multition;
	@FXML
	private Button interProgrammer;
	@FXML
	private Button simpleFactory;
	@FXML
	private Button factory;
	@FXML
	private Button abstractFactory;
	@FXML
	private Button adapter;
	@FXML
	private Button safeComposite;
	@FXML
	private Button consistentComposite;
	@FXML
	private Button hibernateByDao;
	@FXML
	private Button spring;
	@FXML
	private Button springHibernate;

	// Event Listener on Button[#simpleFactory].onAction
	@FXML
	public void Btn_Click(ActionEvent event) {
		if (event.getSource() == interProgrammer) {
			try {
				InterProgrammingClients interProgrammingClients = new InterProgrammingClients();
				interProgrammingClients.start(new Stage());
			} catch (Exception e) {
				e.printStackTrace();
			}
		} else if (event.getSource() == singleton) {
			SingletonClients singletonClients = new SingletonClients();
			singletonClients.start(new Stage());
		} else if (event.getSource() == multition) {
			MultitionClient multitionClient = new MultitionClient();
			multitionClient.start(new Stage());
		} else if (event.getSource() == simpleFactory) {
			try {
				SimpleFactorymethodClient simpleFactorymethodClient = new SimpleFactorymethodClient();
				simpleFactorymethodClient.start(new Stage());
			} catch (Exception e) {
				e.printStackTrace();
			}
		} else if (event.getSource() == factory) {
			try {
				FactoryMethodClients factoryMethodClients = new FactoryMethodClients();
				factoryMethodClients.start(new Stage());
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		} else if (event.getSource() == abstractFactory) {
			try {
				AbstractFactoryMethodClients abstractFactoryMethodClients = new AbstractFactoryMethodClients();
				abstractFactoryMethodClients.start(new Stage());
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		} else if (event.getSource() == adapter) {
			AdapterClients adapterClients = new AdapterClients();
			adapterClients.start(new Stage());
		} else if (event.getSource() == safeComposite) {
			SafeCompositeClients safeCompositeClients = new SafeCompositeClients();
			safeCompositeClients.start(new Stage());
		} else if (event.getSource() == consistentComposite) {
			ConsistentCompositeClients consistentCompositeClients = new ConsistentCompositeClients();
			consistentCompositeClients.start(new Stage());
		} else if (event.getSource() == hibernateByDao) {
			HibernateClientsByDAO hibernateClientsByDAO = new HibernateClientsByDAO();
			hibernateClientsByDAO.start(new Stage());
		} else if (event.getSource() == spring) {
			try {
				SpringClients springClients = new SpringClients();
				springClients.start(new Stage());
			} catch (Exception e) {
				e.printStackTrace();
			}
		} else if (event.getSource() == springHibernate) {
			try {
				SpringHibernateClients springHibernateClients = new SpringHibernateClients();
				springHibernateClients.start(new Stage());
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}
}
